﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SPPD.model;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Linq;

namespace SPPD.controller
{
    class controller_detail_sppd
    {
        crud <detail_sppd> nhi;
        List <detail_sppd> detailsppd;
        public controller_detail_sppd()
        {
            nhi = new crud<detail_sppd>();
            detailsppd = new List<detail_sppd>();
        }
        public void insert(detail_sppd detail_sppd)
        {
            nhi = new crud<detail_sppd>();
            nhi.insert(detail_sppd);
            
        }
        public List<detail_sppd> load()
        {
            var factory = nhi.load();
            using (var session = factory.OpenSession())
            {
                var categories = session.Query<detail_sppd>()
                       .ToList();
                return categories;
            }
            
        }
        public string autogenerate()
        {
            detailsppd = load();
            return "DS" + (detailsppd.Count + 1);
        }

    }
}
